define(function(require) {
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function() {
		this.callParent();
		this.url = "http://yun.jiawoltd.com";
		//this.url = "http://127.0.0.1:8888";
	};

	Model.prototype.flowSelectChange = function(event) {
		var flowId = this.comp("flowSelect").val();
		// 加载批次
		var me = this;
		var ajaxCallUrl = this.url + "/mobile/getBatchByFlowId/" + flowId;
		$.ajax({
			cache : false,
			type : "GET",
			timeout : 1000, // 超时时间设置，单位毫秒
			url : ajaxCallUrl,
			data : {},
			async : false,
			error : function(request) {
			},
			success : function(data) {
				var batchData = me.comp("batch");
				batchData.clear();
				batchData.loadData(data);
			}
		});

	};

	Model.prototype.batchSelectChange = function(event) {
		var batchId = this.comp("batchSelect").val();
		var my = this;
		var ajaxCallUrl = this.url + "/mobile/getPnodeByBatchId/" + batchId;
		$.ajax({
			cache : false,
			type : "GET",
			timeout : 1000, // 超时时间设置，单位毫秒
			url : ajaxCallUrl,
			data : {},
			async : false,
			error : function(request) {
			},
			success : function(data) {
				var pnodeData = my.comp("pnode");
				pnodeData.clear();
				pnodeData.loadData(data);
			}
		});

	};

	Model.prototype.proflowCustomRefresh = function(event) {
		var self = this;
		var userId = localStorage.getItem("USER_ID");
		var ajaxCallUrl = this.url + "/mobile/getPflow/"+userId;
		$.ajax({
			cache : false,
			type : "GET",
			timeout : 1000, // 超时时间设置，单位毫秒
			url : ajaxCallUrl,
			data : {},
			async : false,
			error : function(request) {
			},
			success : function(data) {
				event.source.loadData(data);
			}
		});
	};

	Model.prototype.media1Click = function(event) {
		var batchId = this.comp("batchSelect").val();
		if (batchId) {
			justep.Shell.setIsSinglePage();
			var url = '../scgl/scgl.w';
			justep.Shell.showPage(require.toUrl(url), {
				nodeId : event.bindingContext.$object.val('id'),
				parent : batchId
			});
		}

	};

	return Model;
});